{% extends 'admin/dashboard.html' %}

{% block content %}
<div class="card">
    <h2 class="text-xl font-bold mb-4">{% if carousel %}编辑{% else %}添加{% endif %}轮播图</h2>
    <form method="post" enctype="multipart/form-data">
        <div class="mb-4">
            <label for="title" class="block text-sm font-medium text-gray-700">标题</label>
            <input type="text" id="title" name="title" value="{{ carousel.title if carousel else '' }}" required class="mt-1 p-2 w-full border rounded-md">
        </div>
        <div class="mb-4">
            <label for="sort_order" class="block text-sm font-medium text-gray-700">排序</label>
            <input type="number" id="sort_order" name="sort_order" value="{{ carousel.sort_order if carousel else 0 }}" class="mt-1 p-2 w-full border rounded-md">
        </div>
        <div class="mb-4">
            <label for="image" class="block text-sm font-medium text-gray-700">图片</label>
            {% if carousel and carousel.image_url %}
            <img src="{{ carousel.image_url }}" alt="轮播图" class="w-20 h-20 object-cover mb-2">
            {% endif %}
            <input type="file" id="image" name="image" class="mt-1 p-2 w-full">
        </div>
        <button type="submit" class="px-4 py-2 bg-primary text-white rounded">{% if carousel %}更新{% else %}添加{% endif %}</button>
    </form>
</div>
{% endblock %}